package com.ler.auth.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author leron
 */
@Controller
public class BaseController {

    @GetMapping("/login")
    public String login(HttpServletRequest request) {
        if (isPC(request)) {
            return "pc-login";
        }
        return "login";
    }

    public static boolean isMobile(HttpServletRequest request) {
        String userAgent = request.getHeader("User-Agent");
        return userAgent != null && (userAgent.contains("Android") || userAgent.contains("iPhone") || userAgent.contains("iPad"));
    }

    public static boolean isPC(HttpServletRequest request) {
        String userAgent = request.getHeader("User-Agent");
        return userAgent != null && (userAgent.contains("Windows") || userAgent.contains("Macintosh"));
    }

}